package com.example.demo.service.impl;

import com.alibaba.fastjson2.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.example.demo.entity.Student;
import com.example.demo.service.TestService;
import com.example.demo.service.db.StudentDBService;
import com.example.demo.service.db.UserInfoDBService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;

/**
 * 测试服务实现类
 *
 * @author tulc
 */
@Service
public class TestServiceImpl implements TestService {

    @Autowired
    private StudentDBService studentDBService;
    @Autowired
    private UserInfoDBService userInfoDBService;

    /**
     * 查用户信息
     *
     * @param mobile
     *      手机号
     * @return
     */
    @Override
    public String selectUseInfo(String mobile) {
        List<String> mobileList = userInfoDBService.test(mobile);
        return mobileList == null ? "空" : mobileList.get(0);
    }

    /**
     * 查学生信息
     *
     * @param name
     *      姓名
     * @return
     */
    @Override
    public String selectStudent(String name) {
        Student student = studentDBService.getOne(new LambdaQueryWrapper<Student>()
                .eq(Student::getName,name));
        return JSONObject.toJSONString(student);
    }

}
